﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeChatSDK.Core.对话_发送消息
{
    public class SendMessage
    {
        /// <summary>
        /// 自动回复
        /// </summary>
        /// <returns></returns>
        public string Response(Models.UserMessageModel message)
        {
            //回复XML内容
            return message.ToString();
        }

        /// <summary>
        /// 发送客服信息
        /// </summary>
        public bool SendServiceMsg(string token, Models.UserMessageModel message)
        {
            CommunicateHelper conn = CommunicateHelper.init();

            string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}", conn.Token);
            string data = string.Empty;
            conn.HttpPost(url, data, "application/json", "");

            return true;
        }

        /// <summary>
        /// 模块消息
        /// </summary>
        /// <returns></returns>
        public bool SendModuleMsg(Models.ModuleMessageModel message)
        {
            CommunicateHelper conn = CommunicateHelper.init();
            string url = string.Format("https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={0}", conn.Token);
            string data = string.Empty;
            conn.HttpPost(url, data, "application/json", "");

            return false;
        }
    }
}
